package smecta.client.print.domain;

import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.Transient;
import smecta.client.print.util.web.IdModel;

import javax.persistence.Table;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "scp_sys_settings")
public class ScpSysSettings extends IdModel {

    private String settingKey;

    private String settingValue;

    private String settingValueType;

    private String settingDescription;

    private String settingCategory;

    private Date createdAt;

    private Date updatedAt;

    @Transient
    private List<String> settingValueList = new ArrayList<>();
    
    public void makeSettingValueList(){
        List<String> settingValueList = new ArrayList<>();
        if (StringUtils.isNotBlank(getSettingValue())){
            settingValueList.addAll(Arrays.asList(getSettingValue().split(",")));
        }
        setSettingValueList(settingValueList);
    }
}
